const Mock = require('mockjs')
const Random = Mock.Random

module.exports = [
    {
        url: 'home/base',
        type: 'get',
        result: {
            error: '',
            status: 1,
            data: {
                'CountArticles|10000-99999': 10015,
                'DayArticles|10000-99999': 120,
                'CountComments|100-999': 123,
                'DayComments|0-100': 35
            }
        }
    },
    {
        url: 'home/addMouthArtices',
        type: 'get',
        result: {
            error: '',
            status: 1,
            data: {
                time: () => {
                    let nowTime = []
                    // 本月第一天
                    function showFirstDay() {
                        let Nowdate = new Date()
                        let MonthFirstDay = new Date(
                            Nowdate.getYear(),
                            Nowdate.getMonth(),
                            1
                        ).getDate()
                        return MonthFirstDay
                    }
                    // 当前时间
                    function showLastDay() {
                        let Nowdate = new Date()
                        let MonthLastDay = new Date(Nowdate).getDate()
                        return MonthLastDay
                    }
                    let last = showLastDay()
                    let start = showFirstDay()
                    let date = new Date()
                    for (let i = start; i <= last; i++) {
                        let month = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
                        let day = i < 10 ? '0' + i : i
                        nowTime[i - 1] = date.getFullYear() + '-' + month + '-' + day
                    }
                    return nowTime
                },
                nums: () => {
                    const dataList = []
                    for (let i = 0; i < new Date().getDate(); i++) {
                        const template = Random.integer(10, 30)
                        dataList.push(template)
                    }
                    return dataList
                }
            }
        }
    },
    {
        url: 'home/addClassifyArticles',
        type: 'get',
        result: {
            error: '',
            status: 1,
            data: {
                lData: ['生活', '趣美味', '旅行', '电影', '游泳'],
                sData: [
                    {
                        'value|0-999': 100,
                        name: '生活'
                    },
                    {
                        'value|0-999': 100,
                        name: '趣美味'
                    },
                    {
                        'value|0-999': 100,
                        name: '旅行'
                    },
                    {
                        'value|0-999': 100,
                        name: '电影'
                    },
                    {
                        'value|0-999': 100,
                        name: '游泳'
                    }
                ]
            }
        }
    },
    {
        url: 'home/addClassifyAccess',
        type: 'get',
        result: {
            error: '',
            status: 1,
            data: {
                lData: ['生活', '趣美味', '旅行', '电影', '游泳'],
                xData: () => {
                    let today = new Date()
                    let chinese = [
                        '〇',
                        '一',
                        '二',
                        '三',
                        '四',
                        '五',
                        '六',
                        '七',
                        '八',
                        '九'
                    ]
                    let m = (today.getMonth() + 1).toString()
                    let month = []
                    for (let i = 1; i <= m; i++) {
                        let result = ''
                        if (i.length == 2) {
                            if (i.charAt(0) == '1') {
                                result +=
                                    '十' +
                                    chinese[i.toString().charAt(1)] +
                                    '月'
                            }
                        } else {
                            result += chinese[i.toString().charAt(0)] + '月'
                        }
                        month.push(result)
                    }
                    return month
                },
                sData: [
                    {
                        name: '生活',
                        type: 'bar',
                        data: () => {
                            const dataList = []
                            for (
                                let i = 0;
                                i < new Date().getMonth() + 1;
                                i++
                            ) {
                                const template = Random.integer(0, 999)
                                dataList.push(template)
                            }
                            return dataList
                        }
                    },
                    {
                        name: '趣美味',
                        type: 'bar',
                        data: () => {
                            const dataList = []
                            for (
                                let i = 0;
                                i < new Date().getMonth() + 1;
                                i++
                            ) {
                                const template = Random.integer(0, 999)
                                dataList.push(template)
                            }
                            return dataList
                        }
                    },
                    {
                        name: '旅行',
                        type: 'bar',
                        data: () => {
                            const dataList = []
                            for (
                                let i = 0;
                                i < new Date().getMonth() + 1;
                                i++
                            ) {
                                const template = Random.integer(0, 999)
                                dataList.push(template)
                            }
                            return dataList
                        }
                    },
                    {
                        name: '电影',
                        type: 'bar',
                        data: () => {
                            const dataList = []
                            for (
                                let i = 0;
                                i < new Date().getMonth() + 1;
                                i++
                            ) {
                                const template = Random.integer(0, 999)
                                dataList.push(template)
                            }
                            return dataList
                        }
                    },
                    {
                        name: '游泳',
                        type: 'bar',
                        data: () => {
                            const dataList = []
                            for (
                                let i = 0;
                                i < new Date().getMonth() + 1;
                                i++
                            ) {
                                const template = Random.integer(0, 999)
                                dataList.push(template)
                            }
                            return dataList
                        }
                    }
                ]
            }
        }
    }
]
